#include <iostream>
#include <string>
using namespace std;

struct A{
	int n;
public:
	A(){ cout << "A构造" << endl; }
	A(int n):n(n){ cout << "A构造" << endl; }
	~A(){ cout << "A析构" << endl; }
};
struct B :virtual public A{
	int n;
public:
	B(){ cout << "B构造" << endl; }
	B(int n,int m) :n(n),A(m){ cout << "B构造" << endl; }
	~B(){ cout << "B析构" << endl; }
};
struct C :virtual public A{
	int n;
public:
	C(){ cout << "C 构造" << endl; }
	C(int n, int m) :n(n), A(m){ cout << "C 构造" << endl; }
	~C(){ cout << "C 析构" << endl; }
};
struct D :public B, public C{
	int n;
public:
	D(){ cout << "D 构造" << endl; }
	D(int a,int b,int c,int d,int e,int f):n(a),B(b,c),C(d,e),A(f){ cout << "D 构造" << endl; }
	~D(){ cout << "D 析构" << endl; }
};
int main(){
	D* p = new D(1,2,3,4,5,6);
	cout << p->n << endl;			//1
	cout << p->B::n << endl;		//2
	cout << p->C::n << endl;		//4
	cout << p->B::A::n << endl;		//6
	cout << p->C::A::n << endl;		//6
	delete p;

	while (1);
	return 0;
}